﻿using System;
using Sinacor.Infra.Core.ProcessManager.Server;
using PSE.ProcessManager.Server.InteligenceModules;
using PSE.ProcessManager.Common.Gateway;
using Sinacor.Infra.Common.Exceptions;
using Sinacor.Infra.Service.ExceptionHandling;

namespace Sinacor.Process.Bovespa.Casamento.Server.ProcessImplementation
{
    public class RecasamentoAutomatico : SinacorBaseProcessServer<ProcessLogic.RecasamentoAutomatico>, ISimpleExecutionProcess 
    {
        #region Construtor
        public RecasamentoAutomatico() { }
        #endregion Construtor

        #region Execute
        /// <summary>
        /// Execute
        /// </summary>
        /// <param name="message">BaseMessage</param>
        public void Execute(BaseMessage message)
        {
            try
            {
                //while (!System.Diagnostics.Debugger.IsAttached)
                //    System.Threading.Thread.Sleep(1000);

                ProcessEntity.DadosCasamentoAut _dadosCasamentoAut = message.RetrieveParameter<ProcessEntity.DadosCasamentoAut>();
                this.ProcessLogic.Execute(_dadosCasamentoAut);

            }
            catch (Exception ex)
            {                
                this.HandleException(ex);
            }
            finally
            {
                this.Finalize();
            }
        }        
        #endregion Execute      
    }
}
